package com.dj.ms.configure;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.elasticsearch.ElasticSearchRestHealthContributorAutoConfiguration;
import org.springframework.boot.actuate.elasticsearch.ElasticsearchRestHealthIndicator;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;

import javax.annotation.PostConstruct;

/**
 * <br>
 * <p></p>
 *
 * <br>
 *
 * @author ZJG
 * @version 1.0
 * @date 2021/10/14 上午10:21
 */
@Slf4j
@Configuration
@ConfigurationProperties(prefix = "management.health.elasticsearch", ignoreUnknownFields = false )
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
        ElasticSearchRestHealthContributorAutoConfiguration.class,
        ElasticsearchRestHealthIndicator.class
}))
public class ElasticSearchRestHealthConfiguration {

    @Value("${management.health.elasticsearch:false}")
    private boolean enabled = false;

    @PostConstruct
    public void init() {
        log.info("ElasticSearchRestHealthConfiguration starting...");
    }


    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }
}
